

layui.config({
	version:'1510164124181'
}).use(['form','laydate', 'laypage', 'layer', 'element'],function(){
	form = layui.form;
	layer = layui.layer;
	$ = layui.jquery;
    laydate = layui.laydate;//日期
    laypage = layui.laypage;//分页
    element = layui.element; //元素操作
	inituserdata();
});

function inituserdata(){
	var typeid=$("#CarouseList option:selected").val();
	$.ajax({
		type:"GET",
		url: httpurl+"/carouselist",
		headers: {
			"Access-Control-Allow-Origin": "*",
			"Access-Control-Allow-Methods": "*",
			"Access-Control-Allow-Headers": "Authorization",
			"Authorization": GetTokenInfo()
		},
		contentType : 'application/json',
		cache: false,
		data: {
			"page":pageNo,
			"pagesize":pageRecords,
			"typeid":typeid
		},
		success: function(data){
			layer.closeAll();
			var dataList=data.data.list;
			var info="";
			if(dataList.length>0){
				for (var i=0;i<dataList.length;i++){
					info+='<tr>' +
						'<td><input type="checkbox"  name="box" class="aceChild"/></td>' +
						'<td><img class="carouseimage" src="'+visitimgurl+"/"+dataList[i].picurl+'"/></td>' +
						'<td>'+dataList[i].type+'</td>' +
						'<td>'+dataList[i].sort+'</td>' +
						'<td><a href="AddNotice.html?carouseid='+dataList[i].id+'">编辑</a>&nbsp;&nbsp;<a href="#" data-info="DeleteAdvertInfo" onclick="DeleteInfo(this);" data-id="'+dataList[i].id+'">删除</a></td>' +
						'</tr>';
				}
			}else{
				dataHtml += '<tr>'
					+'<td colspan="12" style="text-align:center;">暂无数据</td>'
					+'</tr>';
			}
			totalRecords =data.data.total;
			$("#tableInfo tbody").html(info);
			page();
		}
	});
}

//分页
function page() {
	laypage.render({
		elem: 'page' //注意，这里的 test1 是 ID，不用加 # 号
		, count: totalRecords //数据总数，从服务端得到
		, curr: pageNo //获取起始页 location.hash.replace('#!fenye=', '')
		, hash: 'fenye' //自定义hash值
		, layout: ['count', 'prev', 'page', 'next', 'skip']
		, jump: function (obj, first) {
			//首次不执行
			if (!first) {
				pageNo = obj.curr;// 当前页数;
				pageRecords = obj.limit;// 当前页面记录数
				inituserdata();
			}
		}
	});
}
